package com.qk.management.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qk.common.PageResult;
import com.qk.entity.OperateLog;
import com.qk.management.mapper.OperateLogMapper;
import com.qk.management.service.OperateLogService;
import com.qk.vo.operateLog.OperateLogVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 *
 * @author lyl
 * @created 2025/10/17 20:17
 * @description
 *
 */
@Service
@SuppressWarnings("all")
public class OperateLogServiceImpl extends ServiceImpl<OperateLogMapper, OperateLog> implements OperateLogService {
    @Autowired
    private OperateLogMapper operateLogMapper;
    @Override
    public PageResult<OperateLogVO> getLogs(String operateUserName, Integer page, Integer pageSize) {
        Page<OperateLogVO> logs = operateLogMapper.getLogs(Page.of(page,pageSize),operateUserName);
        return PageResult.<OperateLogVO>builder()
                .total(Long.valueOf(logs.getTotal()).intValue())
                .rows(logs.getRecords())
                .build();
    }

    @Override
    public void addLog(OperateLog operateLog) {
        this.baseMapper.insert(operateLog);
    }
}
